
<!DOCTYPE html>

<html>
  
<!-- Mirrored from docs.sympy.org/latest/modules/simplify/hyperexpand.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:28:07 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

    <title>Hypergeometric Expansion &#8212; SymPy 1.9 documentation</title>
    <link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/default.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/graphviz.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/plot_directive.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-core.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-autocomplete.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-sphinx.css" />
    
    <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
    <script src="../../_static/jquery.js"></script>
    <script src="../../_static/underscore.js"></script>
    <script src="../../_static/doctools.js"></script>
    <script src="../../../../live.sympy.org/static/utilities.js"></script>
    <script src="../../../../live.sympy.org/static/external/classy.js"></script>
    <script src="../../../../live.sympy.org/static/live-core.js"></script>
    <script src="../../../../live.sympy.org/static/live-autocomplete.js"></script>
    <script src="../../../../live.sympy.org/static/live-sphinx.js"></script>
    <script async="async" src="../../../../cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest8331.js?config=TeX-AMS_HTML-full"></script>
    <script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"inlineMath": [["\\(", "\\)"]], "displayMath": [["\\[", "\\]"]]}})</script>
    
    <link rel="shortcut icon" href="../../_static/sympy-notailtext-favicon.ico"/>
    <link href="hyperexpand.html" rel="canonical" />
    
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="Hongguang Fu’s Trigonometric Simplification" href="fu.html" />
    <link rel="prev" title="Simplify" href="simplify.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="fu.html" title="Hongguang Fu’s Trigonometric Simplification"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="simplify.html" title="Simplify"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" >SymPy Modules Reference</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="index.html" accesskey="U">Simplify</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Hypergeometric Expansion</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="hypergeometric-expansion">
<h1>Hypergeometric Expansion<a class="headerlink" href="#hypergeometric-expansion" title="Permalink to this headline">¶</a></h1>
<p>This page describes how the function <a class="reference internal" href="simplify.html#sympy.simplify.hyperexpand.hyperexpand" title="sympy.simplify.hyperexpand.hyperexpand"><code class="xref py py-func docutils literal notranslate"><span class="pre">hyperexpand()</span></code></a> and related code
work. For usage, see the documentation of the symplify module.</p>
<section id="hypergeometric-function-expansion-algorithm">
<h2>Hypergeometric Function Expansion Algorithm<a class="headerlink" href="#hypergeometric-function-expansion-algorithm" title="Permalink to this headline">¶</a></h2>
<p>This section describes the algorithm used to expand hypergeometric functions.
Most of it is based on the papers <a class="reference internal" href="#roach1996" id="id1"><span>[Roach1996]</span></a> and <a class="reference internal" href="#roach1997" id="id2"><span>[Roach1997]</span></a>.</p>
<p>Recall that the hypergeometric function is (initially) defined as</p>
<div class="math notranslate nohighlight">
\[\begin{split}{}_pF_q\left(\begin{matrix} a_1, \cdots, a_p \\ b_1, \cdots, b_q \end{matrix}
                 \middle| z \right)
    = \sum_{n=0}^\infty \frac{(a_1)_n \cdots (a_p)_n}{(b_1)_n \cdots (b_q)_n}
                        \frac{z^n}{n!}.\end{split}\]</div>
<p>It turns out that there are certain differential operators that can change the
<span class="math notranslate nohighlight">\(a_p\)</span> and <span class="math notranslate nohighlight">\(p_q\)</span> parameters by integers. If a sequence of such
operators is known that converts the set of indices <span class="math notranslate nohighlight">\(a_r^0\)</span> and
<span class="math notranslate nohighlight">\(b_s^0\)</span> into <span class="math notranslate nohighlight">\(a_p\)</span> and <span class="math notranslate nohighlight">\(b_q\)</span>, then we shall say the pair <span class="math notranslate nohighlight">\(a_p,
b_q\)</span> is reachable from <span class="math notranslate nohighlight">\(a_r^0, b_s^0\)</span>. Our general strategy is thus as
follows: given a set <span class="math notranslate nohighlight">\(a_p, b_q\)</span> of parameters, try to look up an origin
<span class="math notranslate nohighlight">\(a_r^0, b_s^0\)</span> for which we know an expression, and then apply the
sequence of differential operators to the known expression to find an
expression for the Hypergeometric function we are interested in.</p>
</section>
<section id="notation">
<h2>Notation<a class="headerlink" href="#notation" title="Permalink to this headline">¶</a></h2>
<p>In the following, the symbol <span class="math notranslate nohighlight">\(a\)</span> will always denote a numerator parameter
and the symbol <span class="math notranslate nohighlight">\(b\)</span> will always denote a denominator parameter. The
subscripts <span class="math notranslate nohighlight">\(p, q, r, s\)</span> denote vectors of that length, so e.g.
<span class="math notranslate nohighlight">\(a_p\)</span> denotes a vector of <span class="math notranslate nohighlight">\(p\)</span> numerator parameters. The subscripts
<span class="math notranslate nohighlight">\(i\)</span> and <span class="math notranslate nohighlight">\(j\)</span> denote “running indices”, so they should usually be used in
conjunction with a “for all <span class="math notranslate nohighlight">\(i\)</span>”. E.g. <span class="math notranslate nohighlight">\(a_i &lt; 4\)</span> for all <span class="math notranslate nohighlight">\(i\)</span>.
Uppercase subscripts <span class="math notranslate nohighlight">\(I\)</span> and <span class="math notranslate nohighlight">\(J\)</span> denote a chosen, fixed index. So
for example <span class="math notranslate nohighlight">\(a_I &gt; 0\)</span> is true if the inequality holds for the one index
<span class="math notranslate nohighlight">\(I\)</span> we are currently interested in.</p>
</section>
<section id="incrementing-and-decrementing-indices">
<h2>Incrementing and decrementing indices<a class="headerlink" href="#incrementing-and-decrementing-indices" title="Permalink to this headline">¶</a></h2>
<p>Suppose <span class="math notranslate nohighlight">\(a_i \ne 0\)</span>. Set <span class="math notranslate nohighlight">\(A(a_i) =
\frac{z}{a_i}\frac{\mathrm{d}}{dz}+1\)</span>. It is then easy to show that
<span class="math notranslate nohighlight">\(A(a_i) {}_p F_q\left({a_p \atop b_q} \middle| z \right) = {}_p F_q\left({a_p +
e_i \atop b_q} \middle| z \right)\)</span>, where <span class="math notranslate nohighlight">\(e_i\)</span> is the i-th unit vector.
Similarly for <span class="math notranslate nohighlight">\(b_j \ne 1\)</span> we set <span class="math notranslate nohighlight">\(B(b_j) = \frac{z}{b_j-1}
\frac{\mathrm{d}}{dz}+1\)</span> and find <span class="math notranslate nohighlight">\(B(b_j) {}_p F_q\left({a_p \atop b_q}
\middle| z \right) = {}_p F_q\left({a_p \atop b_q - e_i} \middle| z \right)\)</span>.
Thus we can increment upper and decrement lower indices at will, as long as we
don’t go through zero. The <span class="math notranslate nohighlight">\(A(a_i)\)</span> and <span class="math notranslate nohighlight">\(B(b_j)\)</span> are called shift
operators.</p>
<p>It is also easy to show that <span class="math notranslate nohighlight">\(\frac{\mathrm{d}}{dz} {}_p F_q\left({a_p
\atop b_q} \middle| z \right) = \frac{a_1 \cdots a_p}{b_1 \cdots b_q} {}_p
F_q\left({a_p + 1 \atop b_q + 1} \middle| z \right)\)</span>, where <span class="math notranslate nohighlight">\(a_p + 1\)</span> is
the vector <span class="math notranslate nohighlight">\(a_1 + 1, a_2 + 1, \ldots\)</span> and similarly for <span class="math notranslate nohighlight">\(b_q + 1\)</span>.
Combining this with the shift operators,  we arrive at one form of the
Hypergeometric differential equation: <span class="math notranslate nohighlight">\(\left[ \frac{\mathrm{d}}{dz}
\prod_{j=1}^q B(b_j) - \frac{a_1 \cdots a_p}{(b_1-1) \cdots (b_q-1)}
\prod_{i=1}^p A(a_i) \right] {}_p F_q\left({a_p \atop b_q} \middle| z \right) =
0\)</span>. This holds if all shift operators are defined, i.e. if no <span class="math notranslate nohighlight">\(a_i = 0\)</span>
and no <span class="math notranslate nohighlight">\(b_j = 1\)</span>. Clearing denominators and multiplying through by z we
arrive at the following equation: <span class="math notranslate nohighlight">\(\left[ z\frac{\mathrm{d}}{dz}
\prod_{j=1}^q \left(z\frac{\mathrm{d}}{dz} + b_j-1 \right) - z \prod_{i=1}^p
\left( z\frac{\mathrm{d}}{\mathrm{d}z} + a_i \right) \right] {}_p F_q\left({a_p
\atop b_q} \middle| z\right) = 0\)</span>. Even though our derivation does not show it,
it can be checked that this equation holds whenever the <span class="math notranslate nohighlight">\({}_p F_q\)</span> is
defined.</p>
<p>Notice that, under suitable conditions on <span class="math notranslate nohighlight">\(a_I, b_J\)</span>, each of the
operators <span class="math notranslate nohighlight">\(A(a_i)\)</span>, <span class="math notranslate nohighlight">\(B(b_j)\)</span> and
<span class="math notranslate nohighlight">\(z\frac{\mathrm{d}}{\mathrm{d}z}\)</span> can be expressed in terms of <span class="math notranslate nohighlight">\(A(a_I)\)</span> or
<span class="math notranslate nohighlight">\(B(b_J)\)</span>. Our next aim is to write the Hypergeometric differential
equation as follows: <span class="math notranslate nohighlight">\([X A(a_I) - r] {}_p F_q\left({a_p \atop b_q}
\middle| z\right) = 0\)</span>, for some operator <span class="math notranslate nohighlight">\(X\)</span> and some constant <span class="math notranslate nohighlight">\(r\)</span>
to be determined. If
<span class="math notranslate nohighlight">\(r \ne 0\)</span>, then we can write this as <span class="math notranslate nohighlight">\(\frac{-1}{r} X {}_p F_q\left({a_p +
e_I \atop b_q} \middle| z\right) = {}_p F_q\left({a_p \atop b_q} \middle|
z\right)\)</span>, and so <span class="math notranslate nohighlight">\(\frac{-1}{r}X\)</span> undoes the shifting of <span class="math notranslate nohighlight">\(A(a_I)\)</span>,
whence it will be called an inverse-shift operator.</p>
<p>Now <span class="math notranslate nohighlight">\(A(a_I)\)</span> exists if <span class="math notranslate nohighlight">\(a_I \ne 0\)</span>, and then
<span class="math notranslate nohighlight">\(z\frac{\mathrm{d}}{\mathrm{d}z} = a_I A(a_I) - a_I\)</span>. Observe also that all the
operators <span class="math notranslate nohighlight">\(A(a_i)\)</span>, <span class="math notranslate nohighlight">\(B(b_j)\)</span> and
<span class="math notranslate nohighlight">\(z\frac{\mathrm{d}}{\mathrm{d}z}\)</span> commute. We have <span class="math notranslate nohighlight">\(\prod_{i=1}^p \left(
z\frac{\mathrm{d}}{\mathrm{d}z} + a_i \right) = \left(\prod_{i=1, i \ne I}^p
\left( z\frac{\mathrm{d}}{\mathrm{d}z} + a_i \right)\right) a_I A(a_I)\)</span>, so
this gives us the first half of <span class="math notranslate nohighlight">\(X\)</span>. The other half does not have such a
nice expression. We find <span class="math notranslate nohighlight">\(z\frac{\mathrm{d}}{dz} \prod_{j=1}^q
\left(z\frac{\mathrm{d}}{dz} + b_j-1 \right) = \left(a_I A(a_I) - a_I\right)
\prod_{j=1}^q \left(a_I A(a_I) - a_I + b_j - 1\right)\)</span>. Since the first
half had no constant term, we infer <span class="math notranslate nohighlight">\(r = -a_I\prod_{j=1}^q(b_j - 1
-a_I)\)</span>.</p>
<p>This tells us under which conditions we can “un-shift” <span class="math notranslate nohighlight">\(A(a_I)\)</span>, namely
when <span class="math notranslate nohighlight">\(a_I \ne 0\)</span> and <span class="math notranslate nohighlight">\(r \ne 0\)</span>. Substituting <span class="math notranslate nohighlight">\(a_I - 1\)</span> for
<span class="math notranslate nohighlight">\(a_I\)</span> then tells us under what conditions we can decrement the index
<span class="math notranslate nohighlight">\(a_I\)</span>. Doing a similar analysis for <span class="math notranslate nohighlight">\(B(a_J)\)</span>, we arrive at the
following rules:</p>
<ul class="simple">
<li><p>An index <span class="math notranslate nohighlight">\(a_I\)</span> can be decremented if <span class="math notranslate nohighlight">\(a_I \ne 1\)</span> and
<span class="math notranslate nohighlight">\(a_I \ne b_j\)</span> for all <span class="math notranslate nohighlight">\(b_j\)</span>.</p></li>
<li><p>An index <span class="math notranslate nohighlight">\(b_J\)</span> can be
incremented if <span class="math notranslate nohighlight">\(b_J \ne -1\)</span> and <span class="math notranslate nohighlight">\(b_J \ne a_i\)</span> for all
<span class="math notranslate nohighlight">\(a_i\)</span>.</p></li>
</ul>
<p>Combined with the conditions (stated above) for the existence of shift
operators, we have thus established the rules of the game!</p>
</section>
<section id="reduction-of-order">
<h2>Reduction of Order<a class="headerlink" href="#reduction-of-order" title="Permalink to this headline">¶</a></h2>
<p>Notice that, quite trivially, if <span class="math notranslate nohighlight">\(a_I = b_J\)</span>, we have <span class="math notranslate nohighlight">\({}_p
F_q\left({a_p \atop b_q} \middle| z \right) = {}_{p-1} F_{q-1}\left({a_p^*
\atop b_q^*} \middle| z \right)\)</span>, where <span class="math notranslate nohighlight">\(a_p^*\)</span> means <span class="math notranslate nohighlight">\(a_p\)</span> with
<span class="math notranslate nohighlight">\(a_I\)</span> omitted, and similarly for <span class="math notranslate nohighlight">\(b_q^*\)</span>. We call this reduction of
order.</p>
<p>In fact, we can do even better. If <span class="math notranslate nohighlight">\(a_I - b_J \in \mathbb{Z}_{&gt;0}\)</span>, then
it is easy to see that <span class="math notranslate nohighlight">\(\frac{(a_I)_n}{(b_J)_n}\)</span> is actually a polynomial
in <span class="math notranslate nohighlight">\(n\)</span>. It is also easy to see that
<span class="math notranslate nohighlight">\((z\frac{\mathrm{d}}{\mathrm{d}z})^k z^n = n^k z^n\)</span>. Combining these two remarks
we find:</p>
<blockquote>
<div><p>If <span class="math notranslate nohighlight">\(a_I - b_J \in \mathbb{Z}_{&gt;0}\)</span>, then there exists a polynomial
<span class="math notranslate nohighlight">\(p(n) = p_0 + p_1 n + \cdots\)</span> (of degree <span class="math notranslate nohighlight">\(a_I - b_J\)</span>) such
that <span class="math notranslate nohighlight">\(\frac{(a_I)_n}{(b_J)_n} = p(n)\)</span> and <span class="math notranslate nohighlight">\({}_p F_q\left({a_p
\atop b_q} \middle| z \right) = \left(p_0 + p_1
z\frac{\mathrm{d}}{\mathrm{d}z} + p_2
\left(z\frac{\mathrm{d}}{\mathrm{d}z}\right)^2 + \cdots \right) {}_{p-1}
F_{q-1}\left({a_p^* \atop b_q^*} \middle| z \right)\)</span>.</p>
</div></blockquote>
<p>Thus any set of parameters <span class="math notranslate nohighlight">\(a_p, b_q\)</span> is reachable from a set of
parameters <span class="math notranslate nohighlight">\(c_r, d_s\)</span> where <span class="math notranslate nohighlight">\(c_i - d_j \in \mathbb{Z}\)</span> implies
<span class="math notranslate nohighlight">\(c_i &lt; d_j\)</span>. Such a set of parameters <span class="math notranslate nohighlight">\(c_r, d_s\)</span> is called
suitable. Our database of known formulae should only contain suitable origins.
The reasons are twofold: firstly, working from suitable origins is easier, and
secondly, a formula for a non-suitable origin can be deduced from a lower order
formula, and we should put this one into the database instead.</p>
</section>
<section id="moving-around-in-the-parameter-space">
<h2>Moving Around in the Parameter Space<a class="headerlink" href="#moving-around-in-the-parameter-space" title="Permalink to this headline">¶</a></h2>
<p>It remains to investigate the following question: suppose <span class="math notranslate nohighlight">\(a_p, b_q\)</span> and
<span class="math notranslate nohighlight">\(a_p^0, b_q^0\)</span> are both suitable, and also <span class="math notranslate nohighlight">\(a_i - a_i^0 \in
\mathbb{Z}\)</span>, <span class="math notranslate nohighlight">\(b_j - b_j^0 \in \mathbb{Z}\)</span>. When is <span class="math notranslate nohighlight">\(a_p, b_q\)</span>
reachable from <span class="math notranslate nohighlight">\(a_p^0, b_q^0\)</span>? It is clear that we can treat all
parameters independently that are incongruent mod 1. So assume that <span class="math notranslate nohighlight">\(a_i\)</span>
and <span class="math notranslate nohighlight">\(b_j\)</span> are congruent to <span class="math notranslate nohighlight">\(r\)</span> mod 1, for all <span class="math notranslate nohighlight">\(i\)</span> and
<span class="math notranslate nohighlight">\(j\)</span>. The same then follows for <span class="math notranslate nohighlight">\(a_i^0\)</span> and <span class="math notranslate nohighlight">\(b_j^0\)</span>.</p>
<p>If <span class="math notranslate nohighlight">\(r \ne 0\)</span>, then any such <span class="math notranslate nohighlight">\(a_p, b_q\)</span> is reachable from any
<span class="math notranslate nohighlight">\(a_p^0, b_q^0\)</span>. To see this notice that there exist constants <span class="math notranslate nohighlight">\(c, c^0\)</span>,
congruent mod 1, such that <span class="math notranslate nohighlight">\(a_i &lt; c &lt; b_j\)</span> for all <span class="math notranslate nohighlight">\(i\)</span> and
<span class="math notranslate nohighlight">\(j\)</span>, and similarly <span class="math notranslate nohighlight">\(a_i^0 &lt; c^0 &lt; b_j^0\)</span>. If <span class="math notranslate nohighlight">\(n = c - c^0 &gt; 0\)</span> then
we first inverse-shift all the <span class="math notranslate nohighlight">\(b_j^0\)</span> <span class="math notranslate nohighlight">\(n\)</span> times up, and then
similarly shift up all the <span class="math notranslate nohighlight">\(a_i^0\)</span> <span class="math notranslate nohighlight">\(n\)</span> times. If <span class="math notranslate nohighlight">\(n &lt;
0\)</span> then we first inverse-shift down the <span class="math notranslate nohighlight">\(a_i^0\)</span> and then shift down the
<span class="math notranslate nohighlight">\(b_j^0\)</span>. This reduces to the case <span class="math notranslate nohighlight">\(c = c^0\)</span>. But evidently we can
now shift or inverse-shift around the <span class="math notranslate nohighlight">\(a_i^0\)</span> arbitrarily so long as we
keep them less than <span class="math notranslate nohighlight">\(c\)</span>, and similarly for the <span class="math notranslate nohighlight">\(b_j^0\)</span> so long as
we keep them bigger than <span class="math notranslate nohighlight">\(c\)</span>. Thus <span class="math notranslate nohighlight">\(a_p, b_q\)</span> is reachable from
<span class="math notranslate nohighlight">\(a_p^0, b_q^0\)</span>.</p>
<p>If <span class="math notranslate nohighlight">\(r = 0\)</span> then the problem is slightly more involved. WLOG no parameter
is zero. We now have one additional complication: no parameter can ever move
through zero. Hence <span class="math notranslate nohighlight">\(a_p, b_q\)</span> is reachable from <span class="math notranslate nohighlight">\(a_p^0, b_q^0\)</span> if
and only if the number of <span class="math notranslate nohighlight">\(a_i &lt; 0\)</span> equals the number of <span class="math notranslate nohighlight">\(a_i^0 &lt;
0\)</span>, and similarly for the <span class="math notranslate nohighlight">\(b_i\)</span> and <span class="math notranslate nohighlight">\(b_i^0\)</span>. But in a suitable set
of parameters, all <span class="math notranslate nohighlight">\(b_j &gt; 0\)</span>! This is because the Hypergeometric function
is undefined if one of the <span class="math notranslate nohighlight">\(b_j\)</span> is a non-positive integer and all
<span class="math notranslate nohighlight">\(a_i\)</span> are smaller than the <span class="math notranslate nohighlight">\(b_j\)</span>. Hence the number of <span class="math notranslate nohighlight">\(b_j \le 0\)</span> is
always zero.</p>
<p>We can thus associate to every suitable set of parameters <span class="math notranslate nohighlight">\(a_p, b_q\)</span>,
where no <span class="math notranslate nohighlight">\(a_i = 0\)</span>, the following invariants:</p>
<blockquote>
<div><ul class="simple">
<li><p>For every <span class="math notranslate nohighlight">\(r \in [0, 1)\)</span> the number <span class="math notranslate nohighlight">\(\alpha_r\)</span> of parameters
<span class="math notranslate nohighlight">\(a_i \equiv r \pmod{1}\)</span>, and similarly the number <span class="math notranslate nohighlight">\(\beta_r\)</span>
of parameters <span class="math notranslate nohighlight">\(b_i \equiv r \pmod{1}\)</span>.</p></li>
<li><p>The number <span class="math notranslate nohighlight">\(\gamma\)</span>
of integers <span class="math notranslate nohighlight">\(a_i\)</span> with <span class="math notranslate nohighlight">\(a_i &lt; 0\)</span>.</p></li>
</ul>
</div></blockquote>
<p>The above reasoning shows that <span class="math notranslate nohighlight">\(a_p, b_q\)</span> is reachable from <span class="math notranslate nohighlight">\(a_p^0,
b_q^0\)</span> if and only if the invariants <span class="math notranslate nohighlight">\(\alpha_r, \beta_r, \gamma\)</span> all
agree. Thus in particular “being reachable from” is a symmetric relation on
suitable parameters without zeros.</p>
</section>
<section id="applying-the-operators">
<h2>Applying the Operators<a class="headerlink" href="#applying-the-operators" title="Permalink to this headline">¶</a></h2>
<p>If all goes well then for a given set of parameters we find an origin in our
database for which we have a nice formula. We now have to apply (potentially)
many differential operators to it. If we do this blindly then the result will
be very messy. This is because with Hypergeometric type functions, the
derivative is usually expressed as a sum of two contiguous functions. Hence if
we compute <span class="math notranslate nohighlight">\(N\)</span> derivatives, then the answer will involve <span class="math notranslate nohighlight">\(2N\)</span>
contiguous functions! This is clearly undesirable. In fact we know from the
Hypergeometric differential equation that we need at most <span class="math notranslate nohighlight">\(\max(p, q+1)\)</span>
contiguous functions to express all derivatives.</p>
<p>Hence instead of differentiating blindly, we will work with a
<span class="math notranslate nohighlight">\(\mathbb{C}(z)\)</span>-module basis: for an origin <span class="math notranslate nohighlight">\(a_r^0, b_s^0\)</span> we either store
(for particularly pretty answers) or compute a set of <span class="math notranslate nohighlight">\(N\)</span> functions
(typically <span class="math notranslate nohighlight">\(N = \max(r, s+1)\)</span>) with the property that the derivative of
any of them is a <span class="math notranslate nohighlight">\(\mathbb{C}(z)\)</span>-linear combination of them. In formulae,
we store a vector <span class="math notranslate nohighlight">\(B\)</span> of <span class="math notranslate nohighlight">\(N\)</span> functions, a matrix <span class="math notranslate nohighlight">\(M\)</span> and a
vector <span class="math notranslate nohighlight">\(C\)</span> (the latter two with entries in <span class="math notranslate nohighlight">\(\mathbb{C}(z)\)</span>), with
the following properties:</p>
<ul class="simple">
<li><p><span class="math notranslate nohighlight">\({}_r F_s\left({a_r^0 \atop b_s^0} \middle| z \right) = C B\)</span></p></li>
<li><p><span class="math notranslate nohighlight">\(z\frac{\mathrm{d}}{\mathrm{d}z} B = M B\)</span>.</p></li>
</ul>
<p>Then we can compute as many derivatives as we want and we will always end up
with <span class="math notranslate nohighlight">\(\mathbb{C}(z)\)</span>-linear combination of at most <span class="math notranslate nohighlight">\(N\)</span> special
functions.</p>
<p>As hinted above, <span class="math notranslate nohighlight">\(B\)</span>, <span class="math notranslate nohighlight">\(M\)</span> and <span class="math notranslate nohighlight">\(C\)</span> can either all be stored
(for particularly pretty answers) or computed from a single <span class="math notranslate nohighlight">\({}_p F_q\)</span>
formula.</p>
</section>
<section id="loose-ends">
<h2>Loose Ends<a class="headerlink" href="#loose-ends" title="Permalink to this headline">¶</a></h2>
<p>This describes the bulk of the hypergeometric function algorithm. There a few
further tricks, described in the hyperexpand.py source file. The extension to
Meijer G-functions is also described there.</p>
<section id="meijer-g-functions-of-finite-confluence">
<h3>Meijer G-Functions of Finite Confluence<a class="headerlink" href="#meijer-g-functions-of-finite-confluence" title="Permalink to this headline">¶</a></h3>
<p>Slater’s theorem essentially evaluates a <span class="math notranslate nohighlight">\(G\)</span>-function as a sum of residues.
If all poles are simple, the resulting series can be recognised as
hypergeometric series. Thus a <span class="math notranslate nohighlight">\(G\)</span>-function can be evaluated as a sum of
Hypergeometric functions.</p>
<p>If the poles are not simple, the resulting series are not hypergeometric. This
is known as the “confluent” or “logarithmic” case (the latter because the
resulting series tend to contain logarithms). The answer depends in a
complicated way on the multiplicities of various poles, and there is no
accepted notation for representing it (as far as I know).
However if there are only finitely many
multiple poles, we can evaluate the <span class="math notranslate nohighlight">\(G\)</span> function as a sum of hypergeometric
functions, plus finitely many extra terms. I could not find any good reference
for this, which is why I work it out here.</p>
<p>Recall the general setup. We define</p>
<div class="math notranslate nohighlight">
\[G(z) = \frac{1}{2\pi i} \int_L \frac{\prod_{j=1}^m \Gamma(b_j - s)
  \prod_{j=1}^n \Gamma(1 - a_j + s)}{\prod_{j=m+1}^q \Gamma(1 - b_j + s)
  \prod_{j=n+1}^p \Gamma(a_j - s)} z^s \mathrm{d}s,\]</div>
<p>where <span class="math notranslate nohighlight">\(L\)</span> is a contour starting and ending at <span class="math notranslate nohighlight">\(+\infty\)</span>, enclosing all of the
poles of <span class="math notranslate nohighlight">\(\Gamma(b_j - s)\)</span> for <span class="math notranslate nohighlight">\(j = 1, \ldots, n\)</span> once in the negative
direction, and no other poles. Also the integral is assumed absolutely
convergent.</p>
<p>In what follows, for any complex numbers <span class="math notranslate nohighlight">\(a, b\)</span>, we write <span class="math notranslate nohighlight">\(a \equiv b \pmod{1}\)</span> if
and only if there exists an integer <span class="math notranslate nohighlight">\(k\)</span> such that <span class="math notranslate nohighlight">\(a - b = k\)</span>. Thus there are
double poles iff <span class="math notranslate nohighlight">\(a_i \equiv a_j \pmod{1}\)</span> for some <span class="math notranslate nohighlight">\(i \ne j \le n\)</span>.</p>
<p>We now assume that whenever <span class="math notranslate nohighlight">\(b_j \equiv a_i \pmod{1}\)</span> for <span class="math notranslate nohighlight">\(i \le m\)</span>, <span class="math notranslate nohighlight">\(j &gt; n\)</span>
then <span class="math notranslate nohighlight">\(b_j &lt; a_i\)</span>. This means that no quotient of the relevant gamma functions
is a polynomial, and can always be achieved by “reduction of order”. Fix a
complex number <span class="math notranslate nohighlight">\(c\)</span> such that <span class="math notranslate nohighlight">\(\{b_i | b_i \equiv c \pmod{1}, i \le  m\}\)</span> is
not empty. Enumerate this set as <span class="math notranslate nohighlight">\(b, b+k_1, \ldots, b+k_u\)</span>, with <span class="math notranslate nohighlight">\(k_i\)</span>
non-negative integers. Enumerate similarly
<span class="math notranslate nohighlight">\(\{a_j | a_j \equiv c \pmod{1}, j &gt; n\}\)</span> as <span class="math notranslate nohighlight">\(b + l_1, \ldots, b + l_v\)</span>.
Then <span class="math notranslate nohighlight">\(l_i &gt; k_j\)</span> for all <span class="math notranslate nohighlight">\(i, j\)</span>. For finite confluence, we need to assume
<span class="math notranslate nohighlight">\(v \ge u\)</span> for all such <span class="math notranslate nohighlight">\(c\)</span>.</p>
<p>Let <span class="math notranslate nohighlight">\(c_1, \ldots, c_w\)</span> be distinct <span class="math notranslate nohighlight">\(\pmod{1}\)</span> and exhaust the congruence classes
of the <span class="math notranslate nohighlight">\(b_i\)</span>. I claim</p>
<div class="math notranslate nohighlight">
\[G(z) = -\sum_{j=1}^w (F_j(z) + R_j(z)),\]</div>
<p>where <span class="math notranslate nohighlight">\(F_j(z)\)</span> is a hypergeometric function and <span class="math notranslate nohighlight">\(R_j(z)\)</span> is a finite sum, both
to be specified later. Indeed corresponding to every <span class="math notranslate nohighlight">\(c_j\)</span> there is
a sequence of poles, at mostly finitely many of them multiple poles. This is where
the <span class="math notranslate nohighlight">\(j\)</span>-th term comes from.</p>
<p>Hence fix again <span class="math notranslate nohighlight">\(c\)</span>, enumerate the relevant <span class="math notranslate nohighlight">\(b_i\)</span> as
<span class="math notranslate nohighlight">\(b, b + k_1, \ldots, b + k_u\)</span>. We will look at the <span class="math notranslate nohighlight">\(a_j\)</span> corresponding to
<span class="math notranslate nohighlight">\(a + l_1, \ldots, a + l_u\)</span>. The other <span class="math notranslate nohighlight">\(a_i\)</span> are not treated specially. The
corresponding gamma functions have poles at (potentially) <span class="math notranslate nohighlight">\(s = b + r\)</span> for
<span class="math notranslate nohighlight">\(r = 0, 1, \ldots\)</span>. For <span class="math notranslate nohighlight">\(r \ge l_u\)</span>, pole of the integrand is simple. We thus set</p>
<div class="math notranslate nohighlight">
\[R(z) = \sum_{r=0}^{l_u - 1} res_{s = r + b}.\]</div>
<p>We finally need to investigate the other poles. Set <span class="math notranslate nohighlight">\(r = l_u + t\)</span>, <span class="math notranslate nohighlight">\(t \ge 0\)</span>.
A computation shows</p>
<div class="math notranslate nohighlight">
\[\frac{\Gamma(k_i - l_u - t)}{\Gamma(l_i - l_u - t)}
     = \frac{1}{(k_i - l_u - t)_{l_i - k_i}}
     = \frac{(-1)^{\delta_i}}{(l_u - l_i + 1)_{\delta_i}}
       \frac{(l_u - l_i + 1)_t}{(l_u - k_i + 1)_t},\]</div>
<p>where <span class="math notranslate nohighlight">\(\delta_i = l_i - k_i\)</span>.</p>
<p>Also</p>
<div class="math notranslate nohighlight">
\[ \begin{align}\begin{aligned}\begin{split}\Gamma(b_j - l_u - b - t) =
    \frac{\Gamma(b_j - l_u - b)}{(-1)^t(l_u + b + 1 - b_j)_t}, \\\end{split}\\\Gamma(1 - a_j + l_u + b + t) =
    \Gamma(1 - a_j + l_u + b) (1 - a_j + l_u + b)_t\end{aligned}\end{align} \]</div>
<p>and</p>
<div class="math notranslate nohighlight">
\[res_{s = b + l_u + t} \Gamma(b - s) = -\frac{(-1)^{l_u + t}}{(l_u + t)!}
          = -\frac{(-1)^{l_u}}{l_u!} \frac{(-1)^t}{(l_u+1)_t}.\]</div>
<p>Hence</p>
<div class="math notranslate nohighlight">
\[\begin{split}res_{s = b + l_u + t} =&amp; -z^{b + l_u}
   \frac{(-1)^{l_u}}{l_u!}
   \prod_{i=1}^{u} \frac{(-1)^{\delta_i}}{(l_u - k_i + 1)_{\delta_i}}
   \frac{\prod_{j=1}^n \Gamma(1 - a_j + l_u + b)
         \prod_{j=1}^m \Gamma(b_j - l_u - b)^*}
        {\prod_{j=n+1}^p \Gamma(a_j - l_u - b)^* \prod_{j=m+1}^q
         \Gamma(1 - b_j + l_u + b)}
   \\ &amp;\times
   z^t
   \frac{(-1)^t}{(l_u+1)_t}
   \prod_{i=1}^{u} \frac{(l_u - l_i + 1)_t}{(l_u - k_i + 1)_t}
   \frac{\prod_{j=1}^n (1 - a_j + l_u + b)_t
         \prod_{j=n+1}^p (-1)^t (l_u + b + 1 - a_j)_t^*}
        {\prod_{j=1}^m (-1)^t (l_u + b + 1 - b_j)_t^*
         \prod_{j=m+1}^q (1 - b_j + l_u + b)_t},\end{split}\]</div>
<p>where the <span class="math notranslate nohighlight">\(*\)</span> means to omit the terms we treated specially.</p>
<p>We thus arrive at</p>
<div class="math notranslate nohighlight">
\[\begin{split}F(z) = C \times {}_{p+1}F_{q}\left(
    \begin{matrix} 1, (1 + l_u - l_i), (1 + l_u + b - a_i)^* \\
                   1 + l_u, (1 + l_u - k_i), (1 + l_u + b - b_i)^*
    \end{matrix} \middle| (-1)^{p-m-n} z\right),\end{split}\]</div>
<p>where <span class="math notranslate nohighlight">\(C\)</span> designates the factor in the residue independent of <span class="math notranslate nohighlight">\(t\)</span>.
(This result can also be written in slightly simpler form by converting
all the <span class="math notranslate nohighlight">\(l_u\)</span> etc back to <span class="math notranslate nohighlight">\(a_* - b_*\)</span>, but doing so is going to require more
notation still and is not helpful for computation.)</p>
</section>
<section id="extending-the-hypergeometric-tables">
<h3>Extending The Hypergeometric Tables<a class="headerlink" href="#extending-the-hypergeometric-tables" title="Permalink to this headline">¶</a></h3>
<p>Adding new formulae to the tables is straightforward. At the top of the file
<code class="docutils literal notranslate"><span class="pre">sympy/simplify/hyperexpand.py</span></code>, there is a function called
<code class="docutils literal notranslate"><span class="pre">add_formulae()</span></code>. Nested in it are defined two helpers,
<code class="docutils literal notranslate"><span class="pre">add(ap,</span> <span class="pre">bq,</span> <span class="pre">res)</span></code> and <code class="docutils literal notranslate"><span class="pre">addb(ap,</span> <span class="pre">bq,</span> <span class="pre">B,</span> <span class="pre">C,</span> <span class="pre">M)</span></code>, as well as dummys
<code class="docutils literal notranslate"><span class="pre">a</span></code>, <code class="docutils literal notranslate"><span class="pre">b</span></code>, <code class="docutils literal notranslate"><span class="pre">c</span></code>, and <code class="docutils literal notranslate"><span class="pre">z</span></code>.</p>
<p>The first step in adding a new formula is by using <code class="docutils literal notranslate"><span class="pre">add(ap,</span> <span class="pre">bq,</span> <span class="pre">res)</span></code>. This
declares <code class="docutils literal notranslate"><span class="pre">hyper(ap,</span> <span class="pre">bq,</span> <span class="pre">z)</span> <span class="pre">==</span> <span class="pre">res</span></code>. Here <code class="docutils literal notranslate"><span class="pre">ap</span></code> and <code class="docutils literal notranslate"><span class="pre">bq</span></code> may use the
dummys <code class="docutils literal notranslate"><span class="pre">a</span></code>, <code class="docutils literal notranslate"><span class="pre">b</span></code>, and <code class="docutils literal notranslate"><span class="pre">c</span></code> as free symbols. For example the well-known formula
<span class="math notranslate nohighlight">\(\sum_0^\infty \frac{(-a)_n z^n}{n!} = (1-z)^a\)</span> is declared by the following
line: <code class="docutils literal notranslate"><span class="pre">add((-a,</span> <span class="pre">),</span> <span class="pre">(),</span> <span class="pre">(1-z)**a)</span></code>.</p>
<p>From the information provided, the matrices <span class="math notranslate nohighlight">\(B\)</span>, <span class="math notranslate nohighlight">\(C\)</span> and <span class="math notranslate nohighlight">\(M\)</span> will be computed,
and the formula is now available when expanding hypergeometric functions.
Next the test file <code class="docutils literal notranslate"><span class="pre">sympy/simplify/tests/test_hyperexpand.py</span></code> should be run,
in particular the test <code class="docutils literal notranslate"><span class="pre">test_formulae()</span></code>. This will test the newly added
formula numerically. If it fails, there is (presumably) a typo in what was
entered.</p>
<p>Since all newly-added formulae are probably relatively complicated, chances
are that the automatically computed basis is rather suboptimal (there is no
good way of testing this, other than observing very messy output). In this
case the matrices <span class="math notranslate nohighlight">\(B\)</span>, <span class="math notranslate nohighlight">\(C\)</span> and <span class="math notranslate nohighlight">\(M\)</span> should be computed by hand. Then the helper
<code class="docutils literal notranslate"><span class="pre">addb</span></code> can be used to declare a hypergeometric formula with hand-computed
basis.</p>
</section>
</section>
<section id="an-example">
<h2>An example<a class="headerlink" href="#an-example" title="Permalink to this headline">¶</a></h2>
<p>Because this explanation so far might be very theoretical and difficult to
understand, we walk through an explicit example now. We take the Fresnel
function <span class="math notranslate nohighlight">\(C(z)\)</span> which obeys the following hypergeometric representation:</p>
<div class="math notranslate nohighlight">
\[\begin{split}C(z) = z \cdot {}_{1}F_{2}\left.\left(
    \begin{matrix} \frac{1}{4} \\
                   \frac{1}{2}, \frac{5}{4}
    \end{matrix} \right| -\frac{\pi^2 z^4}{16}\right) \,.\end{split}\]</div>
<p>First we try to add this formula to the lookup table by using the
(simpler) function <code class="docutils literal notranslate"><span class="pre">add(ap,</span> <span class="pre">bq,</span> <span class="pre">res)</span></code>. The first two arguments
are simply the lists containing the parameter sets of <span class="math notranslate nohighlight">\({}_{1}F_{2}\)</span>.
The <code class="docutils literal notranslate"><span class="pre">res</span></code> argument is a little bit more complicated. We only know
<span class="math notranslate nohighlight">\(C(z)\)</span> in terms of <span class="math notranslate nohighlight">\({}_{1}F_{2}(\ldots | f(z))\)</span> with <span class="math notranslate nohighlight">\(f\)</span>
a function of <span class="math notranslate nohighlight">\(z\)</span>, in our case</p>
<div class="math notranslate nohighlight">
\[f(z) = -\frac{\pi^2 z^4}{16} \,.\]</div>
<p>What we need is a formula where the hypergeometric function has
only <span class="math notranslate nohighlight">\(z\)</span> as argument <span class="math notranslate nohighlight">\({}_{1}F_{2}(\ldots | z)\)</span>. We
introduce the new complex symbol <span class="math notranslate nohighlight">\(w\)</span> and search for a function
<span class="math notranslate nohighlight">\(g(w)\)</span> such that</p>
<div class="math notranslate nohighlight">
\[f(g(w)) = w\]</div>
<p>holds. Then we can replace every <span class="math notranslate nohighlight">\(z\)</span> in <span class="math notranslate nohighlight">\(C(z)\)</span> by <span class="math notranslate nohighlight">\(g(w)\)</span>.
In the case of our example the function <span class="math notranslate nohighlight">\(g\)</span> could look like</p>
<div class="math notranslate nohighlight">
\[g(w) = \frac{2}{\sqrt{\pi}} \exp\left(\frac{i \pi}{4}\right) w^{\frac{1}{4}} \,.\]</div>
<p>We get these functions mainly by guessing and testing the result. Hence
we proceed by computing <span class="math notranslate nohighlight">\(f(g(w))\)</span> (and simplifying naively)</p>
<div class="math notranslate nohighlight">
\[\begin{split}f(g(w)) &amp;= -\frac{\pi^2 g(w)^4}{16} \\
        &amp;= -\frac{\pi^2 g\left(\frac{2}{\sqrt{\pi}} \exp\left(\frac{i \pi}{4}\right) w^{\frac{1}{4}}\right)^4}{16} \\
        &amp;= -\frac{\pi^2 \frac{2^4}{\sqrt{\pi}^4} \exp\left(\frac{i \pi}{4}\right)^4 {w^{\frac{1}{4}}}^4}{16} \\
        &amp;= -\exp\left(i \pi\right) w \\
        &amp;= w\end{split}\]</div>
<p>and indeed get back <span class="math notranslate nohighlight">\(w\)</span>. (In case of branched functions we have to be aware of
branch cuts. In that case we take <span class="math notranslate nohighlight">\(w\)</span> to be a positive real number and check
the formula. If what we have found works for positive <span class="math notranslate nohighlight">\(w\)</span>, then just replace
<a class="reference internal" href="../functions/elementary.html#sympy.functions.elementary.exponential.exp" title="sympy.functions.elementary.exponential.exp"><code class="xref py py-class docutils literal notranslate"><span class="pre">exp</span></code></a> inside any branched
function by <a class="reference internal" href="../functions/elementary.html#sympy.functions.elementary.exponential.exp_polar" title="sympy.functions.elementary.exponential.exp_polar"><code class="xref py py-class docutils literal notranslate"><span class="pre">exp_polar</span></code></a> and what
we get is right for <span class="math notranslate nohighlight">\(all\)</span> <span class="math notranslate nohighlight">\(w\)</span>.) Hence we can write the formula as</p>
<div class="math notranslate nohighlight">
\[\begin{split}C(g(w)) = g(w) \cdot {}_{1}F_{2}\left.\left(
     \begin{matrix} \frac{1}{4} \\
                    \frac{1}{2}, \frac{5}{4}
     \end{matrix} \right| w\right) \,.\end{split}\]</div>
<p>and trivially</p>
<div class="math notranslate nohighlight">
\[\begin{split}{}_{1}F_{2}\left.\left(
\begin{matrix} \frac{1}{4} \\
               \frac{1}{2}, \frac{5}{4}
\end{matrix} \right| w\right)
= \frac{C(g(w))}{g(w)}
= \frac{C\left(\frac{2}{\sqrt{\pi}} \exp\left(\frac{i \pi}{4}\right) w^{\frac{1}{4}}\right)}
       {\frac{2}{\sqrt{\pi}} \exp\left(\frac{i \pi}{4}\right) w^{\frac{1}{4}}}\end{split}\]</div>
<p>which is exactly what is needed for the third parameter,
<code class="docutils literal notranslate"><span class="pre">res</span></code>, in <code class="docutils literal notranslate"><span class="pre">add</span></code>. Finally, the whole function call to add
this rule to the table looks like:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">add</span><span class="p">([</span><span class="n">S</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">/</span><span class="mi">4</span><span class="p">],</span>
    <span class="p">[</span><span class="n">S</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">,</span> <span class="n">S</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span><span class="o">/</span><span class="mi">4</span><span class="p">],</span>
    <span class="n">fresnelc</span><span class="p">(</span><span class="n">exp</span><span class="p">(</span><span class="n">pi</span><span class="o">*</span><span class="n">I</span><span class="o">/</span><span class="mi">4</span><span class="p">)</span><span class="o">*</span><span class="n">root</span><span class="p">(</span><span class="n">z</span><span class="p">,</span><span class="mi">4</span><span class="p">)</span><span class="o">*</span><span class="mi">2</span><span class="o">/</span><span class="n">sqrt</span><span class="p">(</span><span class="n">pi</span><span class="p">))</span> <span class="o">/</span> <span class="p">(</span><span class="n">exp</span><span class="p">(</span><span class="n">pi</span><span class="o">*</span><span class="n">I</span><span class="o">/</span><span class="mi">4</span><span class="p">)</span><span class="o">*</span><span class="n">root</span><span class="p">(</span><span class="n">z</span><span class="p">,</span><span class="mi">4</span><span class="p">)</span><span class="o">*</span><span class="mi">2</span><span class="o">/</span><span class="n">sqrt</span><span class="p">(</span><span class="n">pi</span><span class="p">))</span>
   <span class="p">)</span>
</pre></div>
</div>
<p>Using this rule we will find that it works but the results are not really nice
in terms of simplicity and number of special function instances included.
We can obtain much better results by adding the formula to the lookup table
in another way. For this we use the (more complicated) function <code class="docutils literal notranslate"><span class="pre">addb(ap,</span> <span class="pre">bq,</span> <span class="pre">B,</span> <span class="pre">C,</span> <span class="pre">M)</span></code>.
The first two arguments are again the lists containing the parameter sets of
<span class="math notranslate nohighlight">\({}_{1}F_{2}\)</span>. The remaining three are the matrices mentioned earlier
on this page.</p>
<p>We know that the <span class="math notranslate nohighlight">\(n = \max{\left(p, q+1\right)}\)</span>-th derivative can be
expressed as a linear combination of lower order derivatives. The matrix
<span class="math notranslate nohighlight">\(B\)</span> contains the basis <span class="math notranslate nohighlight">\(\{B_0, B_1, \ldots\}\)</span> and is of shape
<span class="math notranslate nohighlight">\(n \times 1\)</span>. The best way to get <span class="math notranslate nohighlight">\(B_i\)</span> is to take the first
<span class="math notranslate nohighlight">\(n = \max(p, q+1)\)</span> derivatives of the expression for <span class="math notranslate nohighlight">\({}_p F_q\)</span>
and take out useful pieces. In our case we find that
<span class="math notranslate nohighlight">\(n = \max{\left(1, 2+1\right)} = 3\)</span>. For computing the derivatives,
we have to use the operator <span class="math notranslate nohighlight">\(z\frac{\mathrm{d}}{\mathrm{d}z}\)</span>. The
first basis element <span class="math notranslate nohighlight">\(B_0\)</span> is set to the expression for <span class="math notranslate nohighlight">\({}_1 F_2\)</span>
from above:</p>
<div class="math notranslate nohighlight">
\[B_0 = \frac{ \sqrt{\pi} \exp\left(-\frac{\mathbf{\imath}\pi}{4}\right)
C\left( \frac{2}{\sqrt{\pi}} \exp\left(\frac{\mathbf{\imath}\pi}{4}\right) z^{\frac{1}{4}}\right)}
{2 z^{\frac{1}{4}}}\]</div>
<p>Next we compute <span class="math notranslate nohighlight">\(z\frac{\mathrm{d}}{\mathrm{d}z} B_0\)</span>. For this we can
directly use SymPy!</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Symbol</span><span class="p">,</span> <span class="n">sqrt</span><span class="p">,</span> <span class="n">exp</span><span class="p">,</span> <span class="n">I</span><span class="p">,</span> <span class="n">pi</span><span class="p">,</span> <span class="n">fresnelc</span><span class="p">,</span> <span class="n">root</span><span class="p">,</span> <span class="n">diff</span><span class="p">,</span> <span class="n">expand</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">z</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s2">&quot;z&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B0</span> <span class="o">=</span> <span class="n">sqrt</span><span class="p">(</span><span class="n">pi</span><span class="p">)</span><span class="o">*</span><span class="n">exp</span><span class="p">(</span><span class="o">-</span><span class="n">I</span><span class="o">*</span><span class="n">pi</span><span class="o">/</span><span class="mi">4</span><span class="p">)</span><span class="o">*</span><span class="n">fresnelc</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">root</span><span class="p">(</span><span class="n">z</span><span class="p">,</span><span class="mi">4</span><span class="p">)</span><span class="o">*</span><span class="n">exp</span><span class="p">(</span><span class="n">I</span><span class="o">*</span><span class="n">pi</span><span class="o">/</span><span class="mi">4</span><span class="p">)</span><span class="o">/</span><span class="n">sqrt</span><span class="p">(</span><span class="n">pi</span><span class="p">))</span><span class="o">/</span>\
<span class="gp">... </span>         <span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">root</span><span class="p">(</span><span class="n">z</span><span class="p">,</span><span class="mi">4</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">z</span> <span class="o">*</span> <span class="n">diff</span><span class="p">(</span><span class="n">B0</span><span class="p">,</span> <span class="n">z</span><span class="p">)</span>
<span class="go">z*(cosh(2*sqrt(z))/(4*z) - sqrt(pi)*exp(-I*pi/4)*fresnelc(2*z**(1/4)*exp(I*pi/4)/sqrt(pi))/(8*z**(5/4)))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">expand</span><span class="p">(</span><span class="n">_</span><span class="p">)</span>
<span class="go">cosh(2*sqrt(z))/4 - sqrt(pi)*exp(-I*pi/4)*fresnelc(2*z**(1/4)*exp(I*pi/4)/sqrt(pi))/(8*z**(1/4))</span>
</pre></div>
</div>
<p>Formatting this result nicely we obtain</p>
<div class="math notranslate nohighlight">
\[B_1^\prime =
- \frac{1}{4} \frac{
  \sqrt{\pi}
  \exp\left(-\frac{\mathbf{\imath}\pi}{4}\right)
  C\left( \frac{2}{\sqrt{\pi}} \exp\left(\frac{\mathbf{\imath}\pi}{4}\right) z^{\frac{1}{4}}\right)
}
{2 z^{\frac{1}{4}}}
+ \frac{1}{4} \cosh{\left( 2 \sqrt{z} \right )}\]</div>
<p>Computing the second derivative we find</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="p">(</span><span class="n">Symbol</span><span class="p">,</span> <span class="n">cosh</span><span class="p">,</span> <span class="n">sqrt</span><span class="p">,</span> <span class="n">pi</span><span class="p">,</span> <span class="n">exp</span><span class="p">,</span> <span class="n">I</span><span class="p">,</span> <span class="n">fresnelc</span><span class="p">,</span> <span class="n">root</span><span class="p">,</span>
<span class="gp">... </span>                   <span class="n">diff</span><span class="p">,</span> <span class="n">expand</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">z</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s2">&quot;z&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B1prime</span> <span class="o">=</span> <span class="n">cosh</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">sqrt</span><span class="p">(</span><span class="n">z</span><span class="p">))</span><span class="o">/</span><span class="mi">4</span> <span class="o">-</span> <span class="n">sqrt</span><span class="p">(</span><span class="n">pi</span><span class="p">)</span><span class="o">*</span><span class="n">exp</span><span class="p">(</span><span class="o">-</span><span class="n">I</span><span class="o">*</span><span class="n">pi</span><span class="o">/</span><span class="mi">4</span><span class="p">)</span><span class="o">*</span>\
<span class="gp">... </span>          <span class="n">fresnelc</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">root</span><span class="p">(</span><span class="n">z</span><span class="p">,</span><span class="mi">4</span><span class="p">)</span><span class="o">*</span><span class="n">exp</span><span class="p">(</span><span class="n">I</span><span class="o">*</span><span class="n">pi</span><span class="o">/</span><span class="mi">4</span><span class="p">)</span><span class="o">/</span><span class="n">sqrt</span><span class="p">(</span><span class="n">pi</span><span class="p">))</span><span class="o">/</span><span class="p">(</span><span class="mi">8</span><span class="o">*</span><span class="n">root</span><span class="p">(</span><span class="n">z</span><span class="p">,</span><span class="mi">4</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">z</span> <span class="o">*</span> <span class="n">diff</span><span class="p">(</span><span class="n">B1prime</span><span class="p">,</span> <span class="n">z</span><span class="p">)</span>
<span class="go">z*(-cosh(2*sqrt(z))/(16*z) + sinh(2*sqrt(z))/(4*sqrt(z)) + sqrt(pi)*exp(-I*pi/4)*fresnelc(2*z**(1/4)*exp(I*pi/4)/sqrt(pi))/(32*z**(5/4)))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">expand</span><span class="p">(</span><span class="n">_</span><span class="p">)</span>
<span class="go">sqrt(z)*sinh(2*sqrt(z))/4 - cosh(2*sqrt(z))/16 + sqrt(pi)*exp(-I*pi/4)*fresnelc(2*z**(1/4)*exp(I*pi/4)/sqrt(pi))/(32*z**(1/4))</span>
</pre></div>
</div>
<p>which can be printed as</p>
<div class="math notranslate nohighlight">
\[B_2^\prime =
\frac{1}{16} \frac{
  \sqrt{\pi}
  \exp\left(-\frac{\mathbf{\imath}\pi}{4}\right)
  C\left( \frac{2}{\sqrt{\pi}} \exp\left(\frac{\mathbf{\imath}\pi}{4}\right) z^{\frac{1}{4}}\right)
}
{2 z^{\frac{1}{4}}}
- \frac{1}{16} \cosh{\left(2\sqrt{z}\right)}
+ \frac{1}{4} \sinh{\left(2\sqrt{z}\right)} \sqrt{z}\]</div>
<p>We see the common pattern and can collect the pieces. Hence it makes sense to
choose <span class="math notranslate nohighlight">\(B_1\)</span> and <span class="math notranslate nohighlight">\(B_2\)</span> as follows</p>
<div class="math notranslate nohighlight">
\[\begin{split}B =
\left( \begin{matrix}
  B_0 \\ B_1 \\ B_2
\end{matrix} \right)
=
\left( \begin{matrix}
  \frac{
    \sqrt{\pi}
    \exp\left(-\frac{\mathbf{\imath}\pi}{4}\right)
    C\left( \frac{2}{\sqrt{\pi}} \exp\left(\frac{\mathbf{\imath}\pi}{4}\right) z^{\frac{1}{4}}\right)
  }{2 z^{\frac{1}{4}}} \\
  \cosh\left(2\sqrt{z}\right) \\
  \sinh\left(2\sqrt{z}\right) \sqrt{z}
\end{matrix} \right)\end{split}\]</div>
<p>(This is in contrast to the basis <span class="math notranslate nohighlight">\(B = \left(B_0, B_1^\prime, B_2^\prime\right)\)</span> that would
have been computed automatically if we used just <code class="docutils literal notranslate"><span class="pre">add(ap,</span> <span class="pre">bq,</span> <span class="pre">res)</span></code>.)</p>
<p>Because it must hold that <span class="math notranslate nohighlight">\({}_p F_q\left(\cdots \middle| z \right) = C B\)</span>
the entries of <span class="math notranslate nohighlight">\(C\)</span> are obviously</p>
<div class="math notranslate nohighlight">
\[\begin{split}C =
\left( \begin{matrix}
  1 \\ 0 \\ 0
\end{matrix} \right)\end{split}\]</div>
<p>Finally we have to compute the entries of the <span class="math notranslate nohighlight">\(3 \times 3\)</span> matrix <span class="math notranslate nohighlight">\(M\)</span>
such that <span class="math notranslate nohighlight">\(z\frac{\mathrm{d}}{\mathrm{d}z} B = M B\)</span> holds. This is easy.
We already computed the first part <span class="math notranslate nohighlight">\(z\frac{\mathrm{d}}{\mathrm{d}z} B_0\)</span>
above. This gives us the first row of <span class="math notranslate nohighlight">\(M\)</span>. For the second row we have:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Symbol</span><span class="p">,</span> <span class="n">cosh</span><span class="p">,</span> <span class="n">sqrt</span><span class="p">,</span> <span class="n">diff</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">z</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s2">&quot;z&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B1</span> <span class="o">=</span> <span class="n">cosh</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">sqrt</span><span class="p">(</span><span class="n">z</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">z</span> <span class="o">*</span> <span class="n">diff</span><span class="p">(</span><span class="n">B1</span><span class="p">,</span> <span class="n">z</span><span class="p">)</span>
<span class="go">sqrt(z)*sinh(2*sqrt(z))</span>
</pre></div>
</div>
<p>and for the third one</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Symbol</span><span class="p">,</span> <span class="n">sinh</span><span class="p">,</span> <span class="n">sqrt</span><span class="p">,</span> <span class="n">expand</span><span class="p">,</span> <span class="n">diff</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">z</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s2">&quot;z&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B2</span> <span class="o">=</span> <span class="n">sinh</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">sqrt</span><span class="p">(</span><span class="n">z</span><span class="p">))</span><span class="o">*</span><span class="n">sqrt</span><span class="p">(</span><span class="n">z</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">expand</span><span class="p">(</span><span class="n">z</span> <span class="o">*</span> <span class="n">diff</span><span class="p">(</span><span class="n">B2</span><span class="p">,</span> <span class="n">z</span><span class="p">))</span>
<span class="go">sqrt(z)*sinh(2*sqrt(z))/2 + z*cosh(2*sqrt(z))</span>
</pre></div>
</div>
<p>Now we have computed the entries of this matrix to be</p>
<div class="math notranslate nohighlight">
\[\begin{split}M =
\left( \begin{matrix}
  -\frac{1}{4} &amp; \frac{1}{4} &amp; 0 \\
  0            &amp; 0           &amp; 1 \\
  0            &amp; z           &amp; \frac{1}{2} \\
\end{matrix} \right)\end{split}\]</div>
<p>Note that the entries of <span class="math notranslate nohighlight">\(C\)</span> and <span class="math notranslate nohighlight">\(M\)</span> should typically be
rational functions in <span class="math notranslate nohighlight">\(z\)</span>, with rational coefficients. This is all
we need to do in order to add a new formula to the lookup table for
<code class="docutils literal notranslate"><span class="pre">hyperexpand</span></code>.</p>
<section id="implemented-hypergeometric-formulae">
<h3>Implemented Hypergeometric Formulae<a class="headerlink" href="#implemented-hypergeometric-formulae" title="Permalink to this headline">¶</a></h3>
<p>A vital part of the algorithm is a relatively large table of hypergeometric
function representations. The following automatically generated list contains
all the representations implemented in SymPy (of course many more are
derived from them). These formulae are mostly taken from <a class="reference internal" href="#luke1969" id="id3"><span>[Luke1969]</span></a> and
<a class="reference internal" href="#prudnikov1990" id="id4"><span>[Prudnikov1990]</span></a>. They are all tested numerically.</p>
<span class="target" id="module-sympy.simplify.hyperexpand_doc"></span><div class="math notranslate nohighlight">
\[\begin{split}{{}_{0}F_{0}\left(\begin{matrix}  \\  \end{matrix}\middle| {z} \right)} = e^{z}\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{1}F_{0}\left(\begin{matrix} a \\  \end{matrix}\middle| {z} \right)} = \left(1 - z\right)^{- a}\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{2}F_{1}\left(\begin{matrix} a, a - \frac{1}{2} \\ 2 a \end{matrix}\middle| {z} \right)} = 2^{2 a - 1} \left(\sqrt{1 - z} + 1\right)^{1 - 2 a}\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{2}F_{1}\left(\begin{matrix} 1, 1 \\ 2 \end{matrix}\middle| {z} \right)} = - \frac{\log{\left(1 - z \right)}}{z}\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{2}F_{1}\left(\begin{matrix} \frac{1}{2}, 1 \\ \frac{3}{2} \end{matrix}\middle| {z} \right)} = \frac{\operatorname{atanh}{\left(\sqrt{z} \right)}}{\sqrt{z}}\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{2}F_{1}\left(\begin{matrix} \frac{1}{2}, \frac{1}{2} \\ \frac{3}{2} \end{matrix}\middle| {z} \right)} = \frac{\operatorname{asin}{\left(\sqrt{z} \right)}}{\sqrt{z}}\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{2}F_{1}\left(\begin{matrix} a, a + \frac{1}{2} \\ \frac{1}{2} \end{matrix}\middle| {z} \right)} = \frac{\left(\sqrt{z} + 1\right)^{- 2 a}}{2} + \frac{\left(1 - \sqrt{z}\right)^{- 2 a}}{2}\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{2}F_{1}\left(\begin{matrix} a, - a \\ \frac{1}{2} \end{matrix}\middle| {z} \right)} = \cos{\left(2 a \operatorname{asin}{\left(\sqrt{z} \right)} \right)}\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{2}F_{1}\left(\begin{matrix} 1, 1 \\ \frac{3}{2} \end{matrix}\middle| {z} \right)} = \frac{\operatorname{asin}{\left(\sqrt{z} \right)}}{\sqrt{z} \sqrt{1 - z}}\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{2}F_{1}\left(\begin{matrix} \frac{1}{2}, \frac{1}{2} \\ 1 \end{matrix}\middle| {z} \right)} = \frac{2 K\left(z\right)}{\pi}\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{2}F_{1}\left(\begin{matrix} - \frac{1}{2}, \frac{1}{2} \\ 1 \end{matrix}\middle| {z} \right)} = \frac{2 E\left(z\right)}{\pi}\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{3}F_{2}\left(\begin{matrix} - \frac{1}{2}, 1, 1 \\ \frac{1}{2}, 2 \end{matrix}\middle| {z} \right)} = - \frac{2 \sqrt{z} \operatorname{atanh}{\left(\sqrt{z} \right)}}{3} + \frac{2}{3} - \frac{\log{\left(1 - z \right)}}{3 z}\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{3}F_{2}\left(\begin{matrix} - \frac{1}{2}, 1, 1 \\ 2, 2 \end{matrix}\middle| {z} \right)} = \left(\frac{4}{9} - \frac{16}{9 z}\right) \sqrt{1 - z} + \frac{4 \log{\left(\frac{\sqrt{1 - z}}{2} + \frac{1}{2} \right)}}{3 z} + \frac{16}{9 z}\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{1}F_{1}\left(\begin{matrix} 1 \\ b \end{matrix}\middle| {z} \right)} = z^{1 - b} \left(b - 1\right) e^{z} \gamma\left(b - 1, z\right)\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{1}F_{1}\left(\begin{matrix} a \\ 2 a \end{matrix}\middle| {z} \right)} = 4^{a - \frac{1}{2}} z^{\frac{1}{2} - a} e^{\frac{z}{2}} I_{a - \frac{1}{2}}\left(\frac{z}{2}\right) \Gamma\left(a + \frac{1}{2}\right)\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{1}F_{1}\left(\begin{matrix} a \\ a + 1 \end{matrix}\middle| {z} \right)} = a \left(z e^{i \pi}\right)^{- a} \gamma\left(a, z e^{i \pi}\right)\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{1}F_{1}\left(\begin{matrix} - \frac{1}{2} \\ \frac{1}{2} \end{matrix}\middle| {z} \right)} = \sqrt{z} i \sqrt{\pi} \operatorname{erf}{\left(\sqrt{z} i \right)} + e^{z}\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{1}F_{2}\left(\begin{matrix} 1 \\ \frac{3}{4}, \frac{5}{4} \end{matrix}\middle| {z} \right)} = \frac{\sqrt{\pi} \left(i \sinh{\left(2 \sqrt{z} \right)} S\left(\frac{2 \sqrt[4]{z} e^{\frac{i \pi}{4}}}{\sqrt{\pi}}\right) + \cosh{\left(2 \sqrt{z} \right)} C\left(\frac{2 \sqrt[4]{z} e^{\frac{i \pi}{4}}}{\sqrt{\pi}}\right)\right) e^{- \frac{i \pi}{4}}}{2 \sqrt[4]{z}}\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{2}F_{2}\left(\begin{matrix} \frac{1}{2}, a \\ \frac{3}{2}, a + 1 \end{matrix}\middle| {z} \right)} = - \frac{a i \sqrt{\pi} \sqrt{\frac{1}{z}} \operatorname{erf}{\left(\sqrt{z} i \right)}}{2 a - 1} - \frac{a \left(z e^{i \pi}\right)^{- a} \gamma\left(a, z e^{i \pi}\right)}{2 a - 1}\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{2}F_{2}\left(\begin{matrix} 1, 1 \\ 2, 2 \end{matrix}\middle| {z} \right)} = \frac{- \log{\left(z \right)} + \operatorname{Ei}{\left(z \right)}}{z} - \frac{\gamma}{z}\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{0}F_{1}\left(\begin{matrix}  \\ \frac{1}{2} \end{matrix}\middle| {z} \right)} = \cosh{\left(2 \sqrt{z} \right)}\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{0}F_{1}\left(\begin{matrix}  \\ b \end{matrix}\middle| {z} \right)} = z^{\frac{1}{2} - \frac{b}{2}} I_{b - 1}\left(2 \sqrt{z}\right) \Gamma\left(b\right)\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{0}F_{3}\left(\begin{matrix}  \\ \frac{1}{2}, a, a + \frac{1}{2} \end{matrix}\middle| {z} \right)} = 2^{- 2 a} z^{\frac{1}{4} - \frac{a}{2}} \left(I_{2 a - 1}\left(4 \sqrt[4]{z}\right) + J_{2 a - 1}\left(4 \sqrt[4]{z}\right)\right) \Gamma\left(2 a\right)\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{0}F_{3}\left(\begin{matrix}  \\ a, a + \frac{1}{2}, 2 a \end{matrix}\middle| {z} \right)} = \left(2 \sqrt{z} e^{\frac{i \pi}{2}}\right)^{1 - 2 a} I_{2 a - 1}\left(2 \sqrt{2} \sqrt[4]{z} e^{\frac{i \pi}{4}}\right) J_{2 a - 1}\left(2 \sqrt{2} \sqrt[4]{z} e^{\frac{i \pi}{4}}\right) \Gamma^{2}\left(2 a\right)\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{1}F_{2}\left(\begin{matrix} a \\ a - \frac{1}{2}, 2 a \end{matrix}\middle| {z} \right)} = 2 \cdot 4^{a - 1} z^{1 - a} I_{a - \frac{3}{2}}\left(\sqrt{z}\right) I_{a - \frac{1}{2}}\left(\sqrt{z}\right) \Gamma\left(a - \frac{1}{2}\right) \Gamma\left(a + \frac{1}{2}\right) - 4^{a - \frac{1}{2}} z^{\frac{1}{2} - a} I^{2}_{a - \frac{1}{2}}\left(\sqrt{z}\right) \Gamma^{2}\left(a + \frac{1}{2}\right)\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{1}F_{2}\left(\begin{matrix} \frac{1}{2} \\ b, 2 - b \end{matrix}\middle| {z} \right)} = \frac{\pi \left(1 - b\right) I_{1 - b}\left(\sqrt{z}\right) I_{b - 1}\left(\sqrt{z}\right)}{\sin{\left(b \pi \right)}}\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{1}F_{2}\left(\begin{matrix} \frac{1}{2} \\ \frac{3}{2}, \frac{3}{2} \end{matrix}\middle| {z} \right)} = \frac{\operatorname{Shi}{\left(2 \sqrt{z} \right)}}{2 \sqrt{z}}\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{1}F_{2}\left(\begin{matrix} \frac{3}{4} \\ \frac{3}{2}, \frac{7}{4} \end{matrix}\middle| {z} \right)} = \frac{3 \sqrt{\pi} e^{- \frac{3 i \pi}{4}} S\left(\frac{2 \sqrt[4]{z} e^{\frac{i \pi}{4}}}{\sqrt{\pi}}\right)}{4 z^{\frac{3}{4}}}\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{1}F_{2}\left(\begin{matrix} \frac{1}{4} \\ \frac{1}{2}, \frac{5}{4} \end{matrix}\middle| {z} \right)} = \frac{\sqrt{\pi} e^{- \frac{i \pi}{4}} C\left(\frac{2 \sqrt[4]{z} e^{\frac{i \pi}{4}}}{\sqrt{\pi}}\right)}{2 \sqrt[4]{z}}\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{2}F_{3}\left(\begin{matrix} a, a + \frac{1}{2} \\ 2 a, b, 2 a - b + 1 \end{matrix}\middle| {z} \right)} = \left(\frac{\sqrt{z}}{2}\right)^{1 - 2 a} I_{2 a - b}\left(\sqrt{z}\right) I_{b - 1}\left(\sqrt{z}\right) \Gamma\left(b\right) \Gamma\left(2 a - b + 1\right)\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{2}F_{3}\left(\begin{matrix} 1, 1 \\ 2, 2, \frac{3}{2} \end{matrix}\middle| {z} \right)} = \frac{- \log{\left(2 \sqrt{z} \right)} + \operatorname{Chi}\left(2 \sqrt{z}\right)}{z} - \frac{\gamma}{z}\end{split}\]</div>
<div class="math notranslate nohighlight">
\[\begin{split}{{}_{3}F_{3}\left(\begin{matrix} 1, 1, a \\ 2, 2, a + 1 \end{matrix}\middle| {z} \right)} = \frac{a \left(- z\right)^{- a} \left(\Gamma\left(a\right) - \Gamma\left(a, - z\right)\right)}{\left(a - 1\right)^{2}} + \frac{a \left(1 - a\right) \left(\log{\left(- z \right)} + \operatorname{E}_{1}\left(- z\right) + \gamma\right)}{z \left(a^{2} - 2 a + 1\right)} - \frac{a e^{z}}{z \left(a^{2} - 2 a + 1\right)} + \frac{a}{z \left(a^{2} - 2 a + 1\right)}\end{split}\]</div>
</section>
<section id="references">
<h3>References<a class="headerlink" href="#references" title="Permalink to this headline">¶</a></h3>
<dl class="citation">
<dt class="label" id="roach1996"><span class="brackets"><a class="fn-backref" href="#id1">Roach1996</a></span></dt>
<dd><p>Kelly B. Roach.  Hypergeometric Function Representations.
In: Proceedings of the 1996 International Symposium on Symbolic and
Algebraic Computation, pages 301-308, New York, 1996. ACM.</p>
</dd>
<dt class="label" id="roach1997"><span class="brackets"><a class="fn-backref" href="#id2">Roach1997</a></span></dt>
<dd><p>Kelly B. Roach.  Meijer G Function Representations.
In: Proceedings of the 1997 International Symposium on Symbolic and
Algebraic Computation, pages 205-211, New York, 1997. ACM.</p>
</dd>
<dt class="label" id="luke1969"><span class="brackets"><a class="fn-backref" href="#id3">Luke1969</a></span></dt>
<dd><p>Luke, Y. L. (1969), The Special Functions and Their
Approximations, Volume 1.</p>
</dd>
<dt class="label" id="prudnikov1990"><span class="brackets"><a class="fn-backref" href="#id4">Prudnikov1990</a></span></dt>
<dd><p>A. P. Prudnikov, Yu. A. Brychkov and O. I. Marichev (1990).
Integrals and Series: More Special Functions, Vol. 3,
Gordon and Breach Science Publisher.</p>
</dd>
</dl>
</section>
</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../../index.html">
              <img class="logo" src="../../_static/sympylogo.png" alt="Logo"/>
            </a></p>
  <h3><a href="../../index.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Hypergeometric Expansion</a><ul>
<li><a class="reference internal" href="#hypergeometric-function-expansion-algorithm">Hypergeometric Function Expansion Algorithm</a></li>
<li><a class="reference internal" href="#notation">Notation</a></li>
<li><a class="reference internal" href="#incrementing-and-decrementing-indices">Incrementing and decrementing indices</a></li>
<li><a class="reference internal" href="#reduction-of-order">Reduction of Order</a></li>
<li><a class="reference internal" href="#moving-around-in-the-parameter-space">Moving Around in the Parameter Space</a></li>
<li><a class="reference internal" href="#applying-the-operators">Applying the Operators</a></li>
<li><a class="reference internal" href="#loose-ends">Loose Ends</a><ul>
<li><a class="reference internal" href="#meijer-g-functions-of-finite-confluence">Meijer G-Functions of Finite Confluence</a></li>
<li><a class="reference internal" href="#extending-the-hypergeometric-tables">Extending The Hypergeometric Tables</a></li>
</ul>
</li>
<li><a class="reference internal" href="#an-example">An example</a><ul>
<li><a class="reference internal" href="#implemented-hypergeometric-formulae">Implemented Hypergeometric Formulae</a></li>
<li><a class="reference internal" href="#references">References</a></li>
</ul>
</li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="simplify.html"
                        title="previous chapter">Simplify</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="fu.html"
                        title="next chapter">Hongguang Fu’s Trigonometric Simplification</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../../_sources/modules/simplify/hyperexpand.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="https://docs.sympy.org/latest/search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="fu.html" title="Hongguang Fu’s Trigonometric Simplification"
             >next</a> |</li>
        <li class="right" >
          <a href="simplify.html" title="Simplify"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" >SymPy Modules Reference</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="index.html" >Simplify</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Hypergeometric Expansion</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2021 SymPy Development Team.
      Last updated on Sep 30, 2021.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.1.2.
    </div>
  </body>

<!-- Mirrored from docs.sympy.org/latest/modules/simplify/hyperexpand.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:28:07 GMT -->
</html>